<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use Illuminate\Http\Request;


//首页导航相关路由
Route::get('/', 'QuestionController@index');
Route::get('/explore', 'QuestionController@explore');
Route::get('/topic', 'TopicController@index');


//个人相关路由
Auth::routes();
Route::get('/email/verify/{token}','Auth\EmailController@active')->name('email.verify');
Route::get('/setting', 'Auth\SetController@index')->name('auth.set')->middleware('auth');
Route::post('/avatar/upload', 'Auth\SetController@setAvatar');
Route::get('/profile/{user_id}/answer', 'ProfileController@toAnswer')->name('profile.answer');
Route::get('/profile/{user_id}/question', 'ProfileController@toQuestion')->name('profile.question');
Route::get('/profile/{user_id}/follower', 'ProfileController@toFollower')->name('profile.follower');
Route::get('/profile/{user_id}/following', 'ProfileController@toFollowing')->name('profile.following');
Route::get('/profile/{user_id}/followquestion', 'ProfileController@toFollowQuestion')->name('profile.followquestion');
Route::get('/profile/{user_id}/like', 'ProfileController@toLike')->name('profile.like');


//问题相关路由
Route::resource('question','QuestionController');
Route::get('/topics', function (Request $request) {
    $topics = \App\Topic::select('id','title')->where('title','like','%'.$request->query('q').'%')->get();
    return $topics;
});
Route::post('/question/{question_id}/store','AnswerController@store')->name('answer.store');
Route::get('/question/{question_id}/follow','QuestionController@follow')->name('question.follow');
Route::get('/notify','NotifyController@index')->name('notify.index');
Route::get('/inbox/{dialog_id}','MessageController@messageDialog')->name('message.dialog');
Route::post('/inbox/{dialog_id}/store','MessageController@storeDialog');



//CMS相关路由
Route::get('/dashboard', 'AdminController@index');
Route::get('/admin/users', 'AdminController@user');



//非该系统路由
Route::any('/wechat', 'OtherSystem\WechatController@serve');
Route::get('/wechat/user', 'OtherSystem\WechatController@user');
Route::get('/wechat/user/{openId}', 'OtherSystem\WechatController@showUser');

Route::get('/get','OtherSystem\CrawlController@get_data');
Route::post('/voice','OtherSystem\VoiceController@getVoice');
Route::post('/post','OtherSystem\CrawlController@get_data');
